<?php

namespace module\manage\controller;

use app\Controller;
use app\model\UserFocus as Model;

class UserFans extends Controller
{
    /**
     * 列表.
     * 
     */
    public function index()
    {
        $result = Model::scope(['aim'])->withSearch(['user_id'], input('get.'))->paginate([
            'list_rows'=> input('get.pageSize/d', 10),
        ]);
        return json([
            'items' => $result->items(),
            'total' => $result->total()
        ]);
    }    
    /**
     * 详情.
     * 
     * @param int $id
     */
    public function read(int $id)
    {
        $model = Model::with(['user'])->findOrFail($id);
        return json($model->toArray());
    }
}
